package adv_pre;

public class News {
	private int id;
	private String title;
	private String content;
	private String date;

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public News() {
	}

	public News(int id, String title, String content, String date) {
		super();
		this.id = id;
		this.title = title;
		this.content = content;
		this.date = date;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public String getDate() {
		return date;
	}

	public void setDate(String date) {
		this.date = date;
	}

	public static int count = 0;

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((title == null) ? 0 : title.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		News other = (News) obj;
		if (title == null) {
			if (other.title != null)
				return false;
		} else if (!title.equals(other.title))
			return false;
		return true;
	}

	/*
	 * @Override // 以title的hashCode作为对象的hashCode public int hashCode() { // TODO
	 * 自动生成的方法存根 return this.title == null ? 0 : title.hashCode(); }
	 * 
	 * @Override // 标题title作为比较标准 public boolean equals(Object obj) { count++;
	 * if (!(obj instanceof News)) return false; News n = (News) obj; if
	 * (this.title == null) if (n.title == null) return true; else return false;
	 * return this.title.equals(n.title); }
	 */
	@Override
	public String toString() {
		return "News [id=" + id + ", title=" + title + ", content=" + content
				+ ", date=" + date + "]";
	}

}
